/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fri.entiry;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author NguyenDongUIT
 */
@Entity
@Table(name = "fr_userinrole")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FrUserinrole.findAll", query = "SELECT f FROM FrUserinrole f"),
    @NamedQuery(name = "FrUserinrole.findByUserId", query = "SELECT f FROM FrUserinrole f WHERE f.frUserinrolePK.userId = :userId"),
    @NamedQuery(name = "FrUserinrole.findByRoleId", query = "SELECT f FROM FrUserinrole f WHERE f.frUserinrolePK.roleId = :roleId"),
    @NamedQuery(name = "FrUserinrole.findByDateCreated", query = "SELECT f FROM FrUserinrole f WHERE f.dateCreated = :dateCreated")})
public class FrUserinrole implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected FrUserinrolePK frUserinrolePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateCreated")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateCreated;
    @JoinColumn(name = "RoleId", referencedColumnName = "RoleId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private FrRole frRole;
    @JoinColumn(name = "UserId", referencedColumnName = "UserId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private FrUser frUser;

    public FrUserinrole() {
    }

    public FrUserinrole(FrUserinrolePK frUserinrolePK) {
        this.frUserinrolePK = frUserinrolePK;
    }

    public FrUserinrole(FrUserinrolePK frUserinrolePK, Date dateCreated) {
        this.frUserinrolePK = frUserinrolePK;
        this.dateCreated = dateCreated;
    }

    public FrUserinrole(String userId, String roleId) {
        this.frUserinrolePK = new FrUserinrolePK(userId, roleId);
    }

    public FrUserinrolePK getFrUserinrolePK() {
        return frUserinrolePK;
    }

    public void setFrUserinrolePK(FrUserinrolePK frUserinrolePK) {
        this.frUserinrolePK = frUserinrolePK;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public FrRole getFrRole() {
        return frRole;
    }

    public void setFrRole(FrRole frRole) {
        this.frRole = frRole;
    }

    public FrUser getFrUser() {
        return frUser;
    }

    public void setFrUser(FrUser frUser) {
        this.frUser = frUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (frUserinrolePK != null ? frUserinrolePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FrUserinrole)) {
            return false;
        }
        FrUserinrole other = (FrUserinrole) object;
        if ((this.frUserinrolePK == null && other.frUserinrolePK != null) || (this.frUserinrolePK != null && !this.frUserinrolePK.equals(other.frUserinrolePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fri.entiry.FrUserinrole[ frUserinrolePK=" + frUserinrolePK + " ]";
    }
    
}
